Cleanup train keeps rollin' along
authorRobert Lipe <robertlipe@gpsbabel.org>
Mon, 9 Dec 2019 17:30:31 +0000 (11:30 -0600)
committerRobert Lipe <robertlipe@gpsbabel.org>
Mon, 9 Dec 2019 17:30:31 +0000 (11:30 -0600)
defs.h: use c++ true and false. Replace macros with constexprs.
gbser_win.cc don't use Windows style TRUE/FALSE.
kml.cc: integration suggestions.
msvc build: use units.h

defs.h
gbser_win.cc
kml.cc
msvc/GPSBabel.vcxproj
msvc/GPSBabel.vcxproj.filters

diff --git a/defs.h b/defs.h
index b80b26c7b6a711323825155a14c61898a5d95e1d..f8586083b5021e00a74fc1f55f89afeea6e73060 100644 (file)
--- a/defs.h
+++ b/defs.h
 #  define M_PI 3.14159265358979323846
 #endif
 
-#ifndef FALSE
-#  define FALSE false
-#endif
-
-#ifndef TRUE
-#  define TRUE true
-#endif
-
-#define FEET_TO_METERS(feetsies) ((feetsies) * 0.3048)
-#define METERS_TO_FEET(meetsies) ((meetsies) * 3.2808399)
+constexpr double FEET_TO_METERS(double feetsies) { return (feetsies) * 0.3048; };
+constexpr double METERS_TO_FEET(double meetsies) { return (meetsies) * 3.2808399; };
 
-#define NMILES_TO_METERS(a) ((a) * 1852.0)     /* nautical miles */
-#define METERS_TO_NMILES(a) ((a) / 1852.0)
+constexpr double NMILES_TO_METERS(double a) { return a * 1852.0;};     /* nautical miles */
+constexpr double METERS_TO_NMILES(double a) { return a / 1852.0;};
 
-#define MILES_TO_METERS(a) ((a) * 1609.344)
-#define METERS_TO_MILES(a) ((a) / 1609.344)
-#define FATHOMS_TO_METERS(a) ((a) * 1.8288)
+constexpr double MILES_TO_METERS(double a) { return (a) * 1609.344;};
+constexpr double METERS_TO_MILES(double a) { return (a) / 1609.344;};
+constexpr double FATHOMS_TO_METERS(double a) { return (a) * 1.8288;};
 
-#define CELSIUS_TO_FAHRENHEIT(a) (((a) * 1.8) + 32)
-#define FAHRENHEIT_TO_CELSIUS(a) (((a) - 32) / 1.8)
+constexpr double CELSIUS_TO_FAHRENHEIT(double a) { return (((a) * 1.8) + 32);};
+constexpr double FAHRENHEIT_TO_CELSIUS(double a) { return (((a) - 32) / 1.8);};
 
-#define SECONDS_PER_HOUR (60L*60)
-#define SECONDS_PER_DAY (24L*60*60)
+constexpr double SECONDS_PER_HOUR = 60L * 60;
+constexpr double SECONDS_PER_DAY = 24L * 60 * 60;
 
 /* meters/second to kilometers/hour */
-#define MPS_TO_KPH(a) ((a)*SECONDS_PER_HOUR/1000.0)
+constexpr double MPS_TO_KPH(double a) { return (a)*SECONDS_PER_HOUR/1000.0;};
 
 /* meters/second to miles/hour */
-#define MPS_TO_MPH(a) (METERS_TO_MILES(a) * SECONDS_PER_HOUR)
+constexpr double MPS_TO_MPH(double a) { return METERS_TO_MILES(a) * SECONDS_PER_HOUR;};
 
 /* meters/second to knots */
-#define MPS_TO_KNOTS(a) (MPS_TO_KPH((a)/1.852))
+constexpr double MPS_TO_KNOTS(double a) { return MPS_TO_KPH((a)/1.852);};
 
 /* kilometers/hour to meters/second */
-#define KPH_TO_MPS(a) ((a)*1000.0/SECONDS_PER_HOUR)
+constexpr double KPH_TO_MPS(double a) { return a * 1000.0/SECONDS_PER_HOUR;};
 
 /* miles/hour to meters/second */
 #define MPH_TO_MPS(a) (MILES_TO_METERS(a) / SECONDS_PER_HOUR)
 
 /* knots to meters/second */
-#define KNOTS_TO_MPS(a) (KPH_TO_MPS((a)*1.852))
+constexpr double KNOTS_TO_MPS(double a)  {return KPH_TO_MPS(a) * 1.852; };
 
 #define MILLI_TO_MICRO(t) ((t) * 1000)  /* Milliseconds to Microseconds */
 #define MICRO_TO_MILLI(t) ((t) / 1000)  /* Microseconds to Milliseconds*/
index efb510d5c259118b607cb48a45a43f5a0b048325..66271cd9a87abbeb87a1d6728f0bd2b9b039efbf 100644 (file)
@@ -242,19 +242,19 @@ int gbser_set_port(void* handle, unsigned speed, unsigned bits, unsigned parity,
   GetCommState(h->comport, &tio);
 
   tio.BaudRate            = mkspeed(speed);
-  tio.fBinary             = TRUE;
-  tio.fParity             = TRUE;
-  tio.fOutxCtsFlow        = FALSE;
-  tio.fOutxDsrFlow        = FALSE;
+  tio.fBinary             = true;
+  tio.fParity             = true;
+  tio.fOutxCtsFlow        = false;
+  tio.fOutxDsrFlow        = false;
   tio.fDtrControl         = DTR_CONTROL_ENABLE;
-  tio.fDsrSensitivity     = FALSE;
-  tio.fTXContinueOnXoff   = TRUE;
-  tio.fOutX               = FALSE;
-  tio.fInX                = FALSE;
-  tio.fErrorChar          = FALSE;
-  tio.fNull               = FALSE;
+  tio.fDsrSensitivity     = false;
+  tio.fTXContinueOnXoff   = true;
+  tio.fOutX               = false;
+  tio.fInX                = false;
+  tio.fErrorChar          = false;
+  tio.fNull               = false;
   tio.fRtsControl         = RTS_CONTROL_ENABLE;
-  tio.fAbortOnError       = FALSE;
+  tio.fAbortOnError       = false;
   tio.ByteSize            = bits;
   tio.Parity              = parity == 0 ? NOPARITY :
                             (parity == 1 ? ODDPARITY : EVENPARITY);
diff --git a/kml.cc b/kml.cc
index e53e117cf30eab34f5e2c5e05ea3fb371c0dec07..c45a31855a4b50d68adfcefa771623adfcc8f986 100644 (file)
--- a/kml.cc
+++ b/kml.cc
@@ -413,9 +413,9 @@ void trk_coord(xg_string args, const QXmlStreamAttributes*)
   }
   track_add_head(trk_head);
 
-  auto vecs = args.simplified().split(' ');
+  const auto vecs = args.simplified().split(' ');
   for(const auto& vec : vecs) {
-    QStringList coords = vec.split(',');
+    const QStringList coords = vec.split(',');
     auto csize = coords.size();
     auto trkpt = new Waypoint;
 
index 73717c53a1cf433c41feaddfc306cf0dc44155da..3888eaea7315e1a7ca40aa3982e8dc3ba8a1b6e3 100644 (file)
     <ClInclude Include="swapdata.h" />\r
     <ClInclude Include="trackfilter.h" />\r
     <ClInclude Include="transform.h" />\r
+    <ClInclude Include="units.h" />\r
     <ClInclude Include="zlib\trees.h" />\r
     <ClInclude Include="src\core\usasciicodec.h" />\r
     <ClInclude Include="validate.h" />\r
   </ItemGroup>\r
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />\r
   <ImportGroup Label="ExtensionTargets" />\r
-</Project>
\ No newline at end of file
+</Project>\r
index 8bf384f460e260bdc9288fddc4261ce6688f6b47..c999627dff00c22971953aff3f88177c0e1a57ac 100755 (executable)
     <ClInclude Include="src\core\usasciicodec.h">\r
       <Filter>Header Files</Filter>\r
     </ClInclude>\r
+    <ClInclude Include="units.h">\r
+      <Filter>Header Files</Filter>\r
+    </ClInclude>\r
     <ClInclude Include="validate.h">\r
       <Filter>Header Files</Filter>\r
     </ClInclude>\r
       <Filter>Generated Files</Filter>\r
     </CustomBuild>\r
   </ItemGroup>\r
-</Project>
\ No newline at end of file
+</Project>\r